<?php
namespace app\common\validate\Business;
use think\Validate;
class Business extends Validate{
       // 验证规则
       protected $rule = [
        /* 
            require => 字段必填
            regex => 正则验证
            unique => 验证字段值是否为唯一的 支持指定完整模型类 并且默认会优先检测模型类是否存在 不存在则检测数据表
        */
        'mobile' => ['require', 'regex:/^1[3456789]{1}\d{9}$/', 'unique:business'],
        'nickname' => ['require'],
        'password' => ['require']

    ];

    // 错误提示信息
    protected $message = [
        'mobile.require' => '手机号必填',
        'mobile.regex' => '手机号格式错误',
        'mobile.unique' => '手机号已注册',
        'nickname.require' => '密码必填',
        'password.require' => '密码必填',
    ];
      // 验证场景
      protected $scene = [
        // 用户编辑资料的场景
        'edit' => ['nickname'],
        'add'  => ['nickname','mobile'],
    ];
}
?>